<template>
    <div id="search">
        <BackHeader :header="Header"></BackHeader>
        <div class="bg">
                <mt-field placeholder="请输入搜索内容" v-model="value"><a @click="int">搜索</a></mt-field>
        </div>
		    <div class="row bg2" v-if="SRH">
				<div class="col-6 mt10" v-for="(item,index) in searchs" :key="index">
					<div class="card" style="height:210px" >
						<img :src="item.imgs" class="card-img-top" alt="Card image cap" height="100px" @click="mainmsg1(index)">
						<div class="card-body">
							<h6 class="card-title lue_1 title1">{{item.title}}</h6>
							<p class="card-text lue_2 text1">{{item.content}}</p>
						</div>
					</div>
				</div>
			</div>
    </div>
</template>
<script>
import BackHeader from '../../components/Header/BackHeader.vue';
import CommonProvider from "@/providers/CommonProvider";
import { Toast } from "mint-ui";
export default {
    name:'search',
    data(){
        return{
            Header:'搜索',
            value:'',
            searchs:[],
            SRH:true
        }
    },
    methods:{
        mainmsg1(index) {
            window.localStorage.setItem("main_ID", this.searchs[index]._id);
            this.$router.push("/details");
        },
        int(){
            if(this.value==""){
                this.SRH=false
                Toast("没有相关攻略");
            }else{
                let data = {
                    sch:this.value
                }
                CommonProvider.Search(data).then(res => {
                    if(res.data.length==0){  
                        this.SRH=false
                        Toast("没有相关攻略");
                    }else{
                        this.SRH=true
                        this.searchs = res.data;    
                    }
                })
            }
        }
    },
     mounted: function() {
     },
    components:{
		BackHeader
	},
}
</script>
<style lang="scss" scoped>
.card{
  width: 111%;
  margin-left: -10px
}
.bg{
    margin-top: 40px;
}
.title1 {
  font-family: "黑体";
  font-weight: bold;
}
.text1 {
  font-size: 14px;
}
</style>
